#ifndef ALFS_GUI_INVOCABLEUSERCOMMAND_H
#define ALFS_GUI_INVOCABLEUSERCOMMAND_H

// File [alfs/gui/InvocableUserCommand.h].
//
// InvocableUserCommand
//
// An InvocableUserCommand is a UserCommand with a binding to some internal program
// action.
//
// (c) copyright Alf P. Steinbach 2008.
// Use, modification and distribution are subject to the "New BSD License"
// as listed at <url: http://www.opensource.org/licenses/bsd-license.php>.

#include    "UserCommand.h"                     // alfs::UserCommand
#include    <boost/function.hpp>                // boost::function
#include    <boost/bind.hpp>                    // boost::bind, for client code convenience.

namespace alfs{

#   define  ThisClass   InvocableUserCommand

    class ThisClass
        : public UserCommand
    {
    public:
        typedef boost::function<void()>     Action;

        static void noAction();

    private:
        typedef UserCommand     BaseClass;

        Action      myAction;

    protected:
        virtual ~ThisClass();

    public:
        typedef AutoNewPtr<ThisClass>   Ptr;

        ThisClass();
        ThisClass( Id id, std::wstring const& defaultText, Action const& action = &noAction );
        ThisClass( std::wstring const& defaultText, Action const& action = &noAction );

        Action action() const;
        void execute() const;
        void operator()() const     { execute(); }
    };
#   undef   ThisClass
}  // alfs

#endif
